<include file="Public:header" />
<load href="__JS__/upload/uploadify.css" />
<load href="__JS__/swfobject.js" />
<script type="text/javascript" src="__JS__/jquery.uploadify.v2.1.4.min.js"></script> 
<div class="content">
<!-----------------------------------------内容开始--------------------------------------------------->
<div class="infoBox">
<script>
</script>

<form name="form" action="{:U('doshop')}" method="post" onsubmit="return checkform();">
<input type="hidden" name="id" value="{$id}" />

<style>
.infoBoxTd{width:15%;min-width:100px;}
.checkboxml{margin-left:10px;}
.fred{color:#CC0000;}
.zishutishi{width:400px;height:80px;line-height:80px;font-size:22px;padding:0px 40px;color:#f00;background:url(__PUBLIC__/images/btm_bg_hei.png) repeat;position:fixed;left:20%;top:20%;z-index:999;display:none;}
</style>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="basic">
<tr>
	<td class="infoBoxTd">商家名称：</td>
	<td colspan="2"><INPUT name="name" value="{$name}" class="formTitle xzzsinput" size="80" maxlength="30" onkeyup="word_count(30,this)" onblur="auto_save('name')" >您已输入<span class="fred ysrzs">0</span>字，还可输入<span class="fred syzs">30</span>字。</td>
</tr>

<tr>
	<td class="infoBoxTd">商家形象图：</td>
	<td  colspan="2">
		<img id="xxtu" src="<neq name='xxtu' value=''>{$xxtu}<else/>__PUBLIC__/images/nopic.gif</neq>" width="280" height="70" style="float:left;margin-right:20px;" />
		<div class="upimg-box"><div id="fileQueue"></div>
		<input id="file_upload_xxtu" type="file" /><input name="xxtu" type="hidden" value="{$xxtu}" /></div>
	</td>
</tr>

<tr>
	<td class="infoBoxTd">商家LOGO：</td>
	<td  colspan="2">
		<img id="logo" src="<neq name='logo' value=''>{$logo}<else/>__PUBLIC__/images/nopic.gif</neq>" width="140" height="90" style="float:left;margin-right:20px;" />
		<div class="upimg-box"><div id="fileQueue"></div>
		<input id="file_upload_logo" type="file" /><input name="logo" type="hidden" value="{$logo}" /></div>
	</td>
</tr>

<tr>
    <td class="infoBoxTd" >商家基本资料：</td>
    <td colspan="2">
		<textarea id="basinf" name="basinf" style="width:800px;height:300px;" onblur="auto_save('basinf')">{$basinf|stripslashes}</textarea>
		<div>
			您已输入<span id="word_count1" class="fred">0</span>字，还可输入<span id="word_yu1" class="fred">200</span>字。
		</div>
		<div class="zishutishi" id="zishutishi1"></div>
	</td>
</tr>

<tr>
	<td class="infoBoxTd">一句话简介：</td>
	<td colspan="2"><INPUT name="sintro" value="{$sintro}" class="formTitle xzzsinput" size="80" maxlength="50" onkeyup="word_count(50,this)">您已输入<span class="fred ysrzs">0</span>字，还可输入<span class="fred syzs">50</span>字。</td>
</tr>

<tr>
    <td class="infoBoxTd">商家简介：</td>
    <td colspan="2">
		<textarea id="intro" name="intro" style="width:800px;height:300px;" onblur="auto_save('intro')">{$intro|stripslashes}</textarea>
		<div>
			您已输入<span id="word_count2" class="fred">0</span>字，还可输入<span id="word_yu2" class="fred">1000</span>字。
		</div>
		<div class="zishutishi" id="zishutishi2"></div>
	</td>
</tr>

<tr>
	<td class="infoBoxTd">top产品：</td>
	<td colspan="2"><a href="javascript:;" onclick="show_top_prod()" class="buttom">编辑top产品</a></td>
</tr>

<tr>
    <td class="infoBoxTd">商品套系：</td>
    <td colspan="2">
		<textarea id="taoxi" name="taoxi" style="width:800px;height:300px;" onblur="auto_save('taoxi')">{$taoxi|stripslashes}</textarea>
		<div>
			您已输入<span id="word_count3" class="fred">0</span>字，还可输入<span id="word_yu3" class="fred">1000</span>字。最多上传<span class="fred">20</span>张图。
		</div>
		<div class="zishutishi" id="zishutishi3"></div>
	</td>
</tr>

<tr>
	<td class="infoBoxTd">photo相片：</td>
	<td colspan="2"><a href="javascript:;" onclick="show_photo_up()" class="buttom">编辑相片</a></td>
</tr>
<script type="text/javascript">
	function show_photo_up(){
		var id=$("input[name='id']").val();
		if(id){
			var url="{:U('Content/shop_photo_files',array(aid=>$id))}";
			location.href=url;
		}else{
			alert("请先填写其它信息！");
			return false;
		}
	}
	function show_video_up(){
		var id=$("input[name='id']").val();
		if(id){
			var url="{:U('Content/shop_video',array(aid=>$id))}";
			location.href=url;
		}else{
			alert("请先填写其它信息！");
			return false;
		}
	}
	function show_top_prod(){
		var id=$("input[name='id']").val();
		if(id){
			var url="{:U('Content/shop_topphoto',array(aid=>$id))}";
			location.href=url;
		}else{
			alert("请先填写其它信息！");
			return false;
		}
	}
</script>
<tr>
	<td class="infoBoxTd">video视频：</td>
	<td colspan="2"><a href="javascript:;" onclick="show_video_up()" class="buttom">编辑视频</a></td>
</tr>

<tr style="display:none;">
    <td class="infoBoxTd">常见Q&A000 ：</td>
    <td colspan="2"><textarea id="qa000" name="qa000" style="width:800px;height:300px;">{$qa000|stripslashes}</textarea></td>
</tr>

<tr>
    <td class="infoBoxTd">常见Q&A ：</td>
    <td colspan="2">
		<textarea id="qa" name="qa" style="width:800px;height:300px;" onblur="auto_save('qa')">{$qa|stripslashes}</textarea>
		<div>
			您已输入<span id="word_count4" class="fred">0</span>字，还可输入<span id="word_yu4" class="fred">1000</span>字。
		</div>
		<div class="zishutishi" id="zishutishi4"></div>
	</td>
</tr>

<tr>
    <td class="infoBoxTd">注意事项：</td>
    <td colspan="2">
		<textarea id="attention" name="attention" style="width:800px;height:300px;" onblur="auto_save('attention')">{$attention|stripslashes}</textarea>
		<div>
			您已输入<span id="word_count5" class="fred">0</span>字，还可输入<span id="word_yu5" class="fred">500</span>字。
		</div>
		<div class="zishutishi" id="zishutishi5"></div>
	</td>
</tr>

<script>
$(document).ready(function(){
　　$("input[name='area_ids']").on("click",function(){
		var gids = new Array();
		$.each($("input[name='area_ids']:checked"), function(i, n){
			gids.push( $(n).val() );
		});
		var ids=gids.toString();
		$('#area_id').val(ids);
　　});
　　$("input[name='menuids']").on("click",function(){
		var gids = new Array();
		var gnames=new Array();
		$.each($("input[name='menuids']:checked"), function(i, n){
			gids.push($(n).val());
			var menu_name=$(this).parent().find("span.menu_name").text();
			gnames.push(menu_name);
			
		});
		$.each($("input[name='menurids']"), function(){
			if(gnames.indexOf($(this).parent().find("span.menu_name").text())==-1){
				$(this).attr('disabled','disabled');
				$(this).removeAttr("checked");
				pan_menurids();
			}else{
				$(this).removeAttr("disabled"); ;
			}
		});
		$.each($("input[name='menulids']"), function(){
			if(gnames.indexOf($(this).parent().find("span.menu_name").text())==-1){
				$(this).attr('disabled','disabled');
				$(this).removeAttr("checked");
				pan_menulids();
			}else{
				$(this).removeAttr("disabled"); ;
			}
		});
		
		var ids=gids.toString();
		$('#menuid').val(ids);
　　});
　　$("input[name='menurids']").on("click",function(){
		var gids = new Array();
		$.each($("input[name='menurids']:checked"), function(i, n){
			gids.push( $(n).val() );
		});
		var ids=gids.toString();
		$('#menurid').val(ids);
　　});
　　$("input[name='menulids']").on("click",function(){
		var gids = new Array();
		$.each($("input[name='menulids']:checked"), function(i, n){
			gids.push( $(n).val() );
		});
		var ids=gids.toString();
		$('#menulid').val(ids);
　　});
		//页面载入时判断分类项目
		var gnamess=new Array();
		$.each($("input[name='menuids']:checked"), function(){
			var menu_name=$(this).parent().find("span.menu_name").text();
			gnamess.push(menu_name);
			
		});
		$.each($("input[name='menurids']"), function(){
			if(gnamess.indexOf($(this).parent().find("span.menu_name").text())==-1){
				$(this).attr('disabled','disabled');
			}else{
				$(this).removeAttr("disabled"); ;
			}
		});
		$.each($("input[name='menulids']"), function(){
			if(gnamess.indexOf($(this).parent().find("span.menu_name").text())==-1){
				$(this).attr('disabled','disabled');
			}else{
				$(this).removeAttr("disabled"); ;
			}
		});

});
function pan_menurids(){
	var gids = new Array();
	$.each($("input[name='menurids']:checked"), function(i, n){
		gids.push( $(n).val() );
	});
	var ids=gids.toString();
	$('#menurid').val(ids);
}
function pan_menulids(){
	var gids = new Array();
	$.each($("input[name='menulids']:checked"), function(i, n){
		gids.push( $(n).val() );
	});
	var ids=gids.toString();
	$('#menulid').val(ids);
}
</script>

<tr>
	<td class="infoBoxTd">注册时间：</td>
	<td colspan="2"><gt name="ctime" value="0">{$ctime|date='Y-m-d H:i:s',###}</gt></td>
</tr>

<tr>
	<td class="infoBoxTd">上次修改时间：</td>
	<td colspan="2"><gt name="stime" value="0">{$stime|date='Y-m-d H:i:s',###}</gt></td>
</tr>

<tr>
	<td class="infoBoxTd">被阅读次数：</td>
	<td colspan="2">{$reads}</td>
</tr>

<tr>
	<td class="infoBoxTd">被关注次数：</td>
	<td colspan="2">{$follows}</td>
</tr>

</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="infoBoxTd">&nbsp;</td>
<td align="left"><input type="submit" name="Button1" value="保存" class="formInput01" /></td>
</tr>
</table>
</form>
</div>
<!-----------------------------------------内容结束--------------------------------------------------->
</div>
    

<include file="Public:footer" />
<script type="text/javascript">
//字数限制js

function word_count(t,obj){
	var wordleng=$(obj).val().length;
	var syzs=t-wordleng;
	$(obj).parent().find('span.ysrzs').text(wordleng);
	$(obj).parent().find('span.syzs').text(syzs);
}
$(document).ready(function(){
	$("input.xzzsinput").each(function(){
		var wordleng=$(this).val().length;
		var syzs=$(this).parent().find('span.syzs').text()-wordleng;
		$(this).parent().find('span.ysrzs').text(wordleng);
		$(this).parent().find('span.syzs').text(syzs);
	});
	
});
//编辑器
var k1; //商家基本资料
KindEditor.ready(function(K) {
	k1 = K.create('#basinf', {
		allowFileManager : true,
		afterChange : function() {
			K('#word_count1').html(this.count('text'));
			$('#word_yu1').html(200-this.count('text'));
			if(this.count('text')>200){
				$("#zishutishi1").show();
				$("#zishutishi1").text("超出字数限制！无法保存！");
			}else{
				$("#zishutishi1").hide();
				$("#zishutishi1").text("");
			}
		}
	});
});
var k2; //商家简介
KindEditor.ready(function(K) {
	k2 = K.create('#intro', {
		allowFileManager : true,
		afterChange : function() {
			K('#word_count2').html(this.count('text'));
			$('#word_yu2').html(1000-this.count('text'));
			if(this.count('text')>1000){
				$("#zishutishi2").show();
				$("#zishutishi2").text("超出字数限制！无法保存！");
			}else{
				$("#zishutishi2").hide();
				$("#zishutishi2").text("");
			}
		}
	});
});

var k3; //商品套系
KindEditor.ready(function(K) {
	k3 = K.create('#taoxi', {
		allowFileManager : true,
		afterChange : function() {
			K('#word_count3').html(this.count('text'));
			$('#word_yu3').html(1000-this.count('text'));
			if(this.count('text')>1000){
				$("#zishutishi3").show();
				$("#zishutishi3").text("超出字数限制！无法保存！");
			}else{
				$("#zishutishi3").hide();
				$("#zishutishi3").text("");
			}
		}
	});
});

var k400; //常见QA000
KindEditor.ready(function(K) {
	k400 = K.create('#qa000', {
		allowFileManager : true
	});
});

var k4; //常见QA
KindEditor.ready(function(K) {
	k4 = K.create('#qa', {
		allowFileManager : true,
		afterChange : function() {
			K('#word_count4').html(this.count('text'));
			$('#word_yu4').html(1000-this.count('text'));
			if(this.count('text')>1000){
				$("#zishutishi4").show();
				$("#zishutishi4").text("超出字数限制！无法保存！");
			}else{
				$("#zishutishi4").hide();
				$("#zishutishi4").text("");
			}
		}
	});
});

var k5; //注意事项
KindEditor.ready(function(K) {
	k5 = K.create('#attention', {
		allowFileManager : true,
		afterChange : function() {
			K('#word_count5').html(this.count('text'));
			$('#word_yu5').html(500-this.count('text'));
			if(this.count('text')>500){
				$("#zishutishi5").show();
				$("#zishutishi5").text("超出字数限制！无法保存！");
			}else{
				$("#zishutishi5").hide();
				$("#zishutishi5").text("");
			}
		}
	});
});


//图片上传
$("#file_upload_xxtu").uploadify({
		'uploader'       : '__JS__/swf/uploadify.swf',
		'script'         : '__JS__/upload/uploadify.php',
		'cancelImg'      : '__JS__/upload/cancel.png',
		'folder'         : 'data/xxtu',
		'queueID'        : 'fileQueue',
		'sizeLimit'      :	2 * 1000 * 1024,
		'fileExt'        : '*.jpg;*.gif;*.png;', //允许文件上传类型,和fileDesc一起使用.
		'fileDesc'       : '*.jpg;*.gif;*.png;',  //选择文件对话框中的提示文本.
		'auto'           : true,
		'multi'          : false,	
		'onComplete':function(event,queueId,fileObj,response,data){
			$('input[name="xxtu"]').val(response);
			$('#xxtu').attr('src', response);
		}
});

$("#file_upload_logo").uploadify({
		'uploader'       : '__JS__/swf/uploadify.swf',
		'script'         : '__JS__/upload/uploadify.php',
		'cancelImg'      : '__JS__/upload/cancel.png',
		'folder'         : 'data/logo',
		'queueID'        : 'fileQueue',
		'sizeLimit'      :	2 * 1000 * 1024,
		'fileExt'        : '*.jpg;*.gif;*.png;', //允许文件上传类型,和fileDesc一起使用.
		'fileDesc'       : '*.jpg;*.gif;*.png;',  //选择文件对话框中的提示文本.
		'auto'           : true,
		'multi'          : false,	
		'onComplete':function(event,queueId,fileObj,response,data){
			$('input[name="logo"]').val(response);
			$('#logo').attr('src', response);
		}
});

//自动保存
function auto_save(obj){
	var con=$("input[name='"+obj+"']").val();
	var id=$("input[name='id']").val();
	if($(obj).parent().parent().find('div.zishutishi').text()!=''){
		return false;exit;
	}
	$.post("{:U('Content/auto_save_shop')}", {obj:obj,con:con,id:id}, function(v){
		if( v>0 ){
			if(id){
				ui.success('自动保存成功！');
			}else{
				$("input[name='id']").val(v);
				var url="./admin.php?a=editshop&m=content&id="+v+"";
				location.href=url;
			}
		}else{
			//ui.error('自动保存失败！');
		}
	});
}
function checkform(){
	if($('.zishutishi').text()!=''){
		return false;exit;
	}
}

</script>
